package likou.offer;

/**
 * @Info:
 * @Author: 唐小尊
 * @Date: 2020/8/26  10:53
 */
public class _44 {
    public static void main(String[] args) {
        System.out.println(findNthDigit(2147483647));
    }
    public static int findNthDigit(int n) {
        int digit = 1;
        long start = 1;
        long count = 9;
        while (n > count) { // 1.
            n -= count;
            digit += 1;
            start *= 10;
            count = digit * start * 9;
        }
        long num = start + (n - 1) / digit; // 2.
        return Long.toString(num).charAt((n - 1) % digit) - '0'; // 3.
    }
}
